<!--
 * @Author: your name
 * @Date: 2021-04-04 17:02:10
 * @LastEditTime: 2021-04-04 21:34:51
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \JavaScript\02 - 闭包.html
-->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script>
    // var test = (function(i) {
    //   return function() {
    //     alert(i*=2)
    //   }
    // })(2)
    // test(5)

    var a = 0, b = 0;
    function A(a) {
      A = function(b) {
        alert(a + b++)
      }
      alert(a++)
    }
    A(1) // 1
    A(2) // 4
    A(4) // 6
  </script>
</head>
<body>
  
</body>
</html>